﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Boxie
{
    public partial class frmTextEdit : Form
    {
        private bool isUpdating;

        public frmTextEdit()
        {
            InitializeComponent();
            if (BoxieRegLib.GetSettingBool("General/WindowTopMost", true))
                this.TopMost = true;
        }

        private void txtEditor_TextChanged(object sender, EventArgs e)
        {
            if(!isUpdating)
                BoxieWebLib.SendToBoxie("TEUPDT" + txtEditor.Text + ":EOS!");
        }

        public void updateText(string t)
        {
            isUpdating = true;
            int pos = txtEditor.SelectionStart;
            txtEditor.Text = t;
            txtEditor.SelectionStart = pos;
            isUpdating = false;
        }

        private void frmTextEdit_FormClosing(object sender, FormClosingEventArgs e)
        {
            BoxieWebLib.SendToBoxie("TECLOSE");
            Boxie.frmBoxie.instance.fL.add("Text editing session started.", 2);
            Boxie.frmBoxie.instance.fT = null;
        }
    }
}
